const defaultState = {
	inputValue: 'RecoverySky',
	list: [],
}

const reducer = (state = defaultState, action) => {
	const newState = JSON.parse(JSON.stringify(state));
	switch (action.type) {
		case 'changeInput':
			newState.inputValue = action.value;
			return newState;
		case 'addItem':
			newState.list.push(state.inputValue);
			newState.inputValue = '';
			return newState;
		default:
			break;
	}

	return state;
}

export default reducer;
